package com.example.springbootjpa.dao;


import com.example.springbootjpa.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Auther: 郭敬仰
 * @Date: 2019/3/14 15:53
 * @Description:
 */
public interface UserRepository extends JpaRepository<User,Long> {
    @Transactional
    @Modifying
    @Query("delete from User where username = ?1")
    void deleteByUserName(String name);

    @Query("select u from User u where u.username = ?1")
    User findByUserName(String username);
}
